from fastapi import APIRouter, UploadFile, File

news_api = APIRouter() 

@news_api.get("/api/news/page")
def page():
    return {}

@news_api.post("/api/news/upload")
def upload(file:UploadFile = File(...)):
    fileName = file.filename
    fileSize = file.size
    with open("C:\\Users\\Administrator\\Desktop\\web\\fastapi\\www\\upload\\uploadimg.jpg", "wb") as f:
        for chunk in iter(lambda: file.file.read(1024*1024), b''):
            f.write(chunk)
    return {"url":"/www/upload/uploadimg.jpg"}